st = input('Введите скобочную последовательность: ')
sp = ['(',  ')', '[', ']', '{', '}', '<', '>']
for el in st:
    if el not in sp:
        index = st.index(el)
        st = st[:index] + st[index + 1:]
while '()' in st or '[]' in st or '{}' in st:
    st = st.replace('()', '')
    st = st.replace('[]', '')
    st = st.replace('{}', '')
    st = st.replace('<>', '')
if st == str():
    print(True)
else:    
    print((False))